<?php
		//test
		include('handler_bd.php');		
		session_start();
	?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>		
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
				
		<script src="js/jquery-1.9.1.min.js" type="text/javascript"></script>      
        <script src="js/bxSlider/jquery.bxslider.min.js" type="text/javascript"></script>
        <script src="js/misc.js" type="text/javascript"></script>
        <script src="js/cookies.js" type="text/javascript"></script>    
        <script src="facebox/facebox.js" type="text/javascript"></script>
        <script src="http://maps.googleapis.com/maps/api/js?key=AIzaSyCjIkjCCqU6mEQ7NZn1sZmT7daeOoLjA30&sensor=false"></script>
                
        <link rel="shortcut icon" href="img/favicon.ico" />
		<link rel="stylesheet" type="text/css" href="css/styleFijo.css" />
		<link rel="stylesheet" type="text/css" href="js/bxSlider/jquery.bxslider.css"/>	
		<link rel="stylesheet" type="text/css" href="css/maquetado.css" />		
		<link rel="stylesheet" type="text/css" href="facebox/facebox.css" />
				
		<title>T&amp;D Inmobiliaria - Home</title>	
	</head>
	<body>
		<div id="twrapper">
			<div id ="header">
				<div id="logo">
					<img class="img-logo" src="img/logo.png" alt="logo" />
				</div>	
				<div id="slogan">
					<img src="img/slogan.png" alt="un slogan re copado" />
				</div>
				<div id="restoHeader">	
					<div class="menu">				
					<ul class="menu-list">						
					  <li><a id="home" class="active"><span>Home</span></a></li>
					  <li><a id="servicios" ><span>Servicios</span></a></li>
					  <li><a id="empresa"><span>Empresa</span></a></li>
					  <li><a id="autores"><span>Autores</span></a></li>
					</ul>
					</div>
					<button title="Cambiar estilo" id="style" ><img class="imgStyle" src="img/bucketIcon.png" alt="iconito del balde" /></button>
					<a href="admin.php" rel="facebox" rev="iframe|300">					
					<button title="Admin" id="admin" ><img class="imgStyle" src="img/Padlock-icon.png" alt="iconito admin" /></button>
					</a>
				</div>
			</div>
			<div id ="destacados">
				<div class="bxslider">
				<?php
				$des= $conn->query("SELECT * From Propiedades WHERE Destacada='si'");
				foreach($des as $des){ 
					$imgp = $conn->query("SELECT * FROM imagenes WHERE idProp = {$des['id']}") -> fetch();
					?>
					<div class= "destacado" id= "prop <?php echo"{$des['id']}"?>">
					<a href="propiedad.php?propId=<?php echo $des['id']?>" rel="facebox-dest">
					<img class="img-destacados" src="<?php echo "{$imgp['path']}";?>" alt="<?php echo "{$imgp['alt']}";?>" title="<?php echo "{$imgp['nombre']}"?>"/>
					</a>
					</div>
				<?php } ?>
				   	
				</div>
			</div>
			<div id="lateral">
				<div id ="busqueda">
					<h4 align="center">Criterios de búsqueda</h4><br />					
					<form id="formB" action="">
						<table>		
							<tr>				
							<td>Categoria</td>
							<td><select id="scategoria" class="form">
								<?php
									echo "<option>Todas</option>";
									$cats = $conn->query("SELECT * FROM Categorias");
									foreach($cats as $cat){
										echo "<option>$cat[nombre]</option>";
									}
								?>							
							</select></td>
							</tr>
							<tr>							
							<td>Operación</td>							
							<td><select id="soperacion">
								<?php
									echo "<option>Todas</option>";
									$ops = $conn->query("SELECT * FROM Operaciones");
									foreach($ops as $op){
										echo "<option>$op[nombre]</option>";
									}
								?>									
							</select></td>
							</tr>
							<tr>
							<td>Precio</td>
							<td><select id="selPrecio">
									<option>Cualquiera</option>
									<option>Más caro que...</option>
									<option>Más barato que...</option>
									<option>Entre...</option>
								</select>
							</td>
							</tr>
							<tr>
								<td></td>
								<td>
									<div id="camposPrecio">
									<input id="input-filtrado" type="text" name="inputPrecio1" class="inputPrecio" size="4"/>
									</div>
								</td>
							</tr>
						</table><br />				
					</form>
					<div align="center">
						<button id="busquedaBtn" class="botfav">Filtrar</button>
					</div>
				</div>
				<div id ="ordenar">
					<h4 align="center">Ordenar por:</h4><br />	
					<form id="formOrd" action="">
					<table>		
							<tr>
								<td>Campo</td>	
								<td><select id="selcampo">
												<option value="cat">Categoria</option>
												<option value="ope">Operacion</option>
												<option value="precio">Precio</option>
												<option value="direccion">Direccion</option>
												<option value="antiguedad">Antiguedad</option>				
								</select></td>
							</tr>
							<tr>
								<td>Orden</td>
								<td><select id="selorden">
												<option value="ASC">Ascendente</option>
												<option value="DESC">Descendente</option>
														
								</td></select>
							</tr>
					</table><br />
					</form>
					<div align="center">
						<button id="ordenarBtn" class="botfav">Ordenar</button>
					</div>
				</div>
				<div id ="lista">
					<h4 align="center">Lista de favoritos</h4><br />
				</div>
			</div>
			<div id ="propiedades">
				 <div id="props">
				 <div id="content"><?php require('paginador.php'); ?></div>				
				</div> 
			</div> 
			<div id ="footer">
				<br />
				<div align="center">&copy; copyright 2013 - By Duarte-Biscussi</div>
				<div align="center">
				<p>
					<a href="http://validator.w3.org/check?uri=referer"><img src="http://www.w3.org/Icons/valid-xhtml10" alt="Valid XHTML 1.0 Transitional" height="31" width="88" /></a>
					<a href="http://jigsaw.w3.org/css-validator/check/referer">
						<img style="border:0;width:88px;height:31px" src="http://jigsaw.w3.org/css-validator/images/vcss" alt="¡CSS Válido!" />
   					</a>
  				</p>  				
  				</div>				
			</div>
	 	</div>
	 	<?php
			if(isset($_GET['propId'])){								
		?>
		<script type="text/javascript">			
				jQuery.facebox({ ajax: 'propiedad.php?propId='+<?php echo $_GET['propId']?> });			
		</script>
		<?php }
			elseif($_GET['notLogged']){
		?>
		<script type="text/javascript">			
				jQuery.facebox({ ajax: 'admin.php' });			
		</script>
		<?php } ?>
		<script type="text/javascript">
			$('a[rel=facebox-dest]').facebox();			
		</script>	
	</body>
</html>
